import pandas as pd

# 1）准备数据
data = pd.Series([165,174,160,180,159,163,192,184], index=['No1:165', 'No2:174','No3:160', 'No4:180', 'No5:159', 'No6:163', 'No7:192', 'No8:184'])

# 2）分组
# 自动分组
sr1 = pd.qcut(data, 3)
# 自定义分组
bins = [150, 165, 180, 195]
sr2 = pd.cut(data, bins)

# 查看分组情况
sr1.value_counts()
sr2.value_counts()

# 3）转换成one-hot编码
pd.get_dummies(sr1, prefix="height1")
pd.get_dummies(sr2, prefix="height2")


